<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
        <title>Graph Drawing Demo</title>
        <script type="text/javascript" src="graphbase.js">
        </script>
        <style type="text/css">
            canvas { border: 1px solid black; }
        </style>

        <script type="text/javascript">
            function setupCNV(){
                start()
                // get the canvas element using the DOM
                var canvas = document.getElementById('canvas');
                // Make sure we don't execute when canvas isn't supported
                if (canvas.getContext){
                    // use getContext to use the canvas for drawing
                    //var ctx = canvas.getContext('2d');
                    //var G = new Graph({},[],ctx);
                    var nnodes = 10
                    var nodes = new Array()
                    var edges = new Array()
                    for (var i=0; i<nnodes; i++){
                        nodes.push(new Node('Node '+i,400,250,30,'rgba(0,255,100,1)',ctx))
                    }
                    graph.addNodesFrom(nodes)
                    while (edges.length < 15){
                        var n1 = Math.floor(Math.random()*nnodes)
                        var n2 = Math.floor(Math.random()*nnodes)
                        if (Math.random()<0.5){
                            var e = new Edge(nodes[n1],nodes[n2],10,true)
                            graph.addEdge(e)
                            edges.push(e)
                        }
                    }
                    
                    setupRepellants()
                    graph.render();
                    /*
for (var i = 0; i < graph.nodes.length; i++){
                                                document.write(graph.nodes[i].repellants.toString())
                                        }
                     */
                    go()
                }
                else {
                    alert('You need Safari or Firefox 1.5+ to see this demo.');
                }
            }
        </script>
    </head>
    <body onload ="setupCNV();">
        <div>
            <h1>Graph canvas</h1>
            <canvas id="canvas" width="800" height="500"></canvas>
        </div>
    </body>
</html>
